package com.cloud.message.controller;

import com.cloud.common.bean.PageInfo;
import com.cloud.common.bean.ResultInfo;
import com.cloud.message.dto.PendingQueryParamDTO;
import com.cloud.message.entity.MessagePending;
import com.cloud.message.service.MessagePendingService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 消息待处理接口
 */
@Slf4j
@RestController
public class PendingController {

    @Autowired
    private MessagePendingService messagePendingService;

    /**
     * 查询待处理消息
     *
     * @param paramDTO
     * @return ResultInfo
     */
    @PostMapping("/message/pending/query")
    public ResultInfo<PageInfo<MessagePending>> query(@Valid @RequestBody PendingQueryParamDTO paramDTO) {
        PageInfo<MessagePending> pageInfo = messagePendingService.getPage(paramDTO);
        return ResultInfo.success().setData(pageInfo);
    }
}

